from django.shortcuts import render

# Create your views here.

#
#
# #
# import jenkins
#
#
#
# server = jenkins.Jenkins("http://192.168.5.217:808", username="admin", password="1234")
#
# try:
#     joblist = server.get_all_jobs()
# except:
#     server = jenkins.Jenkins("http://192.168.5.217:8080", username="admin", password="1234")
#
#
# joblist = server.get_all_jobs()
#
# print(joblist)

#
#
#
#









# #
# #
# #
# a = open('./template/jenkins-web.txt', 'r+', encoding='UTF-8').read()
# print(a)
#
# import requests
# import re

# host = "http://192.168.5.216:3000"
# token = "2cf746919e07474107ec0475d31a7e710b172272"
# name = "ops/dev-soft"
# branch = "dev"
#
# r = requests.get(host + '/api/v1/repos/'
#                  + name + '/branches'
#                  + "?access_token=" + token
#                  )
#
# response_list = r.json()
#
# for a in response_list:
#     if str(a['name']).strip() == branch:
#         date = str(a['commit']['timestamp']).strip()
#
# print(date)
# sub_str = (re.sub(u"([^\u4e00-\u9fa5\u0030-\u0039\u0041-\u005a\u0061-\u007a])", "", date)[2:-6])
#
# print(sub_str)
#
# sub_str = (date.replace("T", ".")
#            .replace("-", "")
#            .replace("+", "")
#            .replace(":", "")
# )
# print(sub_str)
#
#
#
#
# sub_str = sub_str[2:-6]
# print(sub_str)
#
#
# from urllib.parse import urlparse
#
# git_url = "http://192.168.5.216:3000/tc/tc-test.git"
#
#
# print(urlparse(git_url).scheme)
# print(urlparse(git_url).netloc,
#       urlparse(git_url).path[1:-4]
# )


#
# import datetime, time
# print(time.time())
# #当前小时
# print(time.strftime('%H', time.localtime(time.time())))
#

# import paramiko
#
# ssh = paramiko.SSHClient()
# ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# ssh.connect(hostname="192.168.5.213", port=22, username="root", password="nancal.123")
#
# name = "zookeeper"
# ver = "3.6.2"
#
#
# stdin, stdout, stderr = ssh.exec_command("for i in $(kubectl get pod -A|grep " + name + "| awk '{print $2}');do pid=$(kubectl describe pod   $i|grep Image:|grep " + ver + "|wc -l); if [ $pid -eq 1 ];then kubectl get pod $i |awk '{print $3}'|grep -v STATUS ;break   ;fi   ;done", get_pty=True)
# res, err = stdout.read(), stderr.read()
# print(res)
# if err:
#     print(err)
#
#
#
#

